package cn.cloud.all.security.oauth2.common.exceptions;

import cn.cloud.all.security.oauth2.common.util.OAuth2Utils;

import java.util.Set;

@SuppressWarnings("serial")
public class InsufficientScopeException extends OAuth2Exception {

    public InsufficientScopeException(String msg, Set<String> validScope) {
        this(msg);
        addAdditionalInformation("scope", OAuth2Utils.formatParameterList(validScope));
    }

    public InsufficientScopeException(String msg) {
        super(msg);
    }

    @Override
    public int getHttpErrorCode() {
        return 403;
    }

    @Override
    public String getOAuth2ErrorCode() {
        // Not defined in the spec, so not really an OAuth2Exception
        return "insufficient_scope";
    }
}